<template>
  <div class="item-detail">
    <div class="image">
      <img :src="item.image.replace('140x140', '640x640')" />
      <a class="btn btn-back" href="javascript:;"
        @click="$emit('close')">Back</a>
    </div>

    <div class="info">
      <h1 class="title">{{item.name}}</h1>
      <strong class="price"><i>&yen;</i>{{item.price}}</strong>
      <button-buy v-model="item.count"></button-buy>
    </div>
  </div>
</template>

<script>
import ButtonBuy from 'components/common/ButtonBuy'

export default {
  name: 'ItemDetail',
  components: {
    ButtonBuy
  },
  props: {
    item: {
      type: Object,
      default() {
        return {
          id: '',
          name: '',
          image: '',
          price: '0.00',
          count: 0
        }
      }
    }
  },

  methods: {
    buy(count) {
      this.item.count = count
      console.log('buy', this.item.count, this.item)
    }
  }
}
</script>

<style lang="less">
.item-detail {
  z-index: 1000;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;

  .image {
    position: relative;
    width: 100%;
    height: 0;
    padding-top: 100%;

    img {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
    }

    .btn-back {
      position: absolute;
      left: 10px;
      top: 10px;
      display: block;
      padding: 5px 10px;
      border-radius: 500px;
      background-color: rgba(0, 0, 0, 0.5);
      color: #fff;
      text-align: center;
    }
  }

  .info {
    padding: 10px;
    text-align: center;

    .title {
      margin: 0 0 15px 0;
      font-weight: normal;
      font-size: 18px;
    }

    .price {
      display: block;
      font-weight: normal;
      font-size: 21px;
      color: #ff3366;
      margin: 15px 0;

      i {
        font-style: normal;
        font-size: 0.5em;
      }
    }
  }
}
</style>
